import { http } from "@/utils/http";

// https://api.shodan.io/shodan/host/{ip}?key=ivpQMs45TYimeuWqW97anU4BMYahsCsl
const baseUrl = "/api/shodan";

const api_key = "ivpQMs45TYimeuWqW97anU4BMYahsCsl";

export type ResultOfHost = {
  country_code: "";
  country_name: "";
  region_code: "";
  area_code: "";
  asn: "";
  isp: "";
  latitude: "";
  longitude: "";
  org: "";
  city: "";
  ports: [];
  last_update: "";
  data: [];
};

export const searchIP = ipaddress => {
  const params = {
    key: api_key
  };

  return http.request<ResultOfHost>("get", baseUrl + "/host/" + ipaddress, {
    params
  });
};
